<?php
    if(isset($javascript)):
// load script in <head> section
        echo $html->charset("UTF-8");
        echo $javascript->link('scriptaculous/lib/prototype', false);
        echo $javascript->link('scriptaculous/src/scriptaculous', false);
        //echo $javascript->link('scriptaculous/src/effects', false);
        //echo $javascript->link('scriptaculous/src/controls', false);
    endif;
?>
<?php if (count($committees)) { ?>
<div class = "keywordsearch_wrap">
    <div class="keywordsearch">
    <?php echo $form->create('Committee',array('url'=>array('action'=>'find')));?>
    <?php echo '<strong>'.__('Search',true).':</strong';?>
    <?php echo $html->div('input',$ajax->autoComplete('Search.text','/getmultidata',array('onfocus'=>"if(this.value=='".__('Type keyword and press enter to search',true)."') this.value='';", 'onblur'=>"if(this.value=='') this.value='".__('Type keyword and press enter to search',true)."';" ,'value'=>__("Type keyword and press enter to search",true),'size'=>"35"))); ?>
    <?php echo $form->end();?>
    </div>
</div>
<?php } ?>

<div id="mainpage_wrap">
    <div id="newupdates">
        <h2><?php __('My tasks')?></h2>

        <div class='content'>
    <?php 
    if(!empty($pending_attendance) || !empty($taken_attendance) || !empty($pending_approval) || !empty($minute_comment)){
        ?>
            <?php
            echo "<h3>".__('Confirm attendance',true)."</h3>";
            if(!empty($pending_attendance)){
                echo '<ul>';
                foreach($pending_attendance as $p){
                    echo '<li>';
                    echo $p['Meeting']['meeting_title'].", ".$p['Meeting']['meeting_num']." ";
                    echo $html->link(__('Confirm your attendance',true),'/hash/'.$p['Hash']['Hash']['hash']);
                    echo '</li>';
                }
                echo '</ul>';
            } else {
                __('No record');
            }
            
            echo "<h3>".__('Edit attendance',true)."</h3>";
            if(!empty($taken_attendance)){
                echo '<ul>';
                foreach($taken_attendance as $t){
                    echo '<li>';
                    echo $t['Meeting']['meeting_title'].", ".$t['Meeting']['meeting_num']." ";
                    echo $html->link(__('Edit',true),'/hash/'.$t['Hash']['Hash']['hash']);
                    echo '</li>';
                }
                echo '</ul>';
            } else {
                __('No record');
            }
            
            echo "<h3>".__('Minute approval',true)."</h3>";
            if(!empty($pending_approval)){
                echo '<ul>';
                foreach($pending_approval as $p){
                    echo '<li>';
                    echo $p['Meeting']['meeting_title'].", ".$p['Meeting']['meeting_num']." ";
                    echo $html->link(__('Approve this minute',true),'/'.$p['Committee']['short_name'].'/decisions/printminutes/'.$p['Meeting']['id'],array('target'=>'_blank'));
                    echo '</li>';
                }
                echo '</ul>';
            } else {
                __('No record');
            }
            
            echo "<h3>".__('Minute comment',true)."</h3>";
            if(!empty($minute_comment)){
                echo '<ul>';
                foreach($minute_comment as $m){
                    echo '<li>';
                    echo $m['Meeting']['meeting_title'].", ".$m['Meeting']['meeting_num']." ";
                    echo $html->link(__('View the minute comment',true),'/'.$m['Committee']['short_name'].'/decisions/printminutes/'.$m['Meeting']['id'],array('target'=>'_blank'));
                    echo '</li>';
                }
                echo '</ul>';
            } else {
                __('No record');
            }
            ?>
    <?php
    } else {
        __('No tasks');
    }
    ?>
        </div>
    </div>
    
    
    <div id="mainpage">
        <div>
        <span class="head"><?php __("My committees")?></span><p>&nbsp;</p>
        <span class="instructions"><?php __("The following is a list of committees you're involved in. To call for a new meeting, update current status or add new committee member, please click on the appropriate committee name to continue:")?></span>
        </div>

        <div>
        <table  cellspacing="0" cellpadding="0" align="left" id="comm_list">

<?php
$i = 0;
$y=0;

foreach($committees as $key=>$com){
    if (strpos($key,'_details') === false) {
        echo "<tr>";
        echo "<td class='committee'>".$html->link($com,array('committee'=>$committees[$key.'_details']['0']['short_name'],'controller'=>'committees','action'=>'alert')).'</td>';

        echo "<td>";
        if ($committees[$key.'_details']['0']['pnc']==1) echo $form->label('(pnc)');
        echo "</td>";
        echo "<td>";
        if($committees[$key.'_details']['0']['create_committee']) echo $html->link($html->image('icons/committee_add1.gif', array('title'=>__('Create: Click here to create a sub-committee',true),'alt'=>__('Click here to add a sub-committee',true))),array('committee'=>$committees[$key.'_details']['0']['short_name'],'controller'=>'committees','action'=>'addsubcomm','id'=>$key),array('escape'=>false));
        echo "</td>";
        echo "<td>";
        if($committees[$key.'_details']['0']['edit_committee']) echo $html->link($html->image('icons/edit.gif', array('title'=>__('Edit: Click here to edit this committee',true),'alt'=>__('Click here to edit this committee',true))),array('committee'=>$committees[$key.'_details']['0']['short_name'],'controller'=>'committees','action'=>'edit','id'=>$key),array('escape'=>false));
        echo "</td>";
        echo "<td>";
        if($committees[$key.'_details']['0']['delete_committee']) echo $html->link($html->image('icons/delete.gif', array('title'=>__('Delete: Delete this committee',true),'alt'=>__('Click here to delete this committee',true))),array('committee'=>$committees[$key.'_details']['0']['short_name'],'controller'=>'committees','action'=>'delete'),array('escape'=>false),sprintf(__('Are you sure you want to delete commitee called %s?', true),$com));
        echo "</td>";
        echo "<td>";
        if($committees[$key.'_details']['0']['edit_wfmodels']) echo $html->link($html->image('icons/workflow.gif',array('title'=>__('Permissions: Click here to navigate to permission management',true),'alt'=>__('Click here to navigate to workflow management',true))),array('committee'=>$committees[$key.'_details']['0']['short_name'],'controller'=>'wfmodels','action'=>'index'),array('escape'=>false));
        echo "</td>";
        echo "<td>";
        if($committees[$key.'_details']['0']['edit_announcements']) echo $html->link($html->image('icons/agt_announcements-24.gif', array('title'=>__('Announcements: Click here to navigate to committee announcements',true),'alt'=>__('Click here to navigate to committee announcements',true))),array('committee'=>$committees[$key.'_details']['0']['short_name'],'controller'=>'announcements','action'=>'index'),array('escape'=>false));
        echo "</td>";
        echo "<td>";
        /*if($committees[$key.'_details']['0']['view_memberships'])*/ echo $html->link($html->image('icons/users.png',array('title'=>__('Users: Click here to navigate to committee users management',true),'alt'=>__('Click here to navigate to committee users management',true))),array('committee'=>$committees[$key.'_details']['0']['short_name'],'controller'=>'memberships','action'=>'index'),array('escape'=>false));
        echo "</td>";
        echo "<td>";
        if($committees[$key.'_details']['0']['edit_todos']) echo $html->link($html->image('icons/todos1.gif',array('title'=>__('To-dos: Click here to navigate to committee to-dos management',true),'alt'=>__('Click here to navigate to committee to-dos management',true))),array('committee'=>$committees[$key.'_details']['0']['short_name'],'controller'=>'committeetodos','action'=>'index'),array('escape'=>false));
        echo "</td>";
        echo "<td>";
        if($committees[$key.'_details']['0']['edit_templates']) echo $html->link($html->image('icons/template.png', array('title'=>__('Messages: Click here to navigate to committee messages management',true),'alt'=>__('Click here to navigate to committee messages management',true))),array('committee'=>$committees[$key.'_details']['0']['short_name'],'controller'=>'Templates','action'=>'index'),array('escape'=>false));
        echo "</tr>";
    }
}
if (!count($committees)) {
    echo "<tr><td colspan='2'>".__(" You are not registered under any committee yet",true)." </td></tr>";
}


?>
        </table>
        </div>
    
    </div>
</div>


<?php if($auth_user['User']['superuser']):?>
<div id="othertasks">
    <div class="head"><?php __("Other tasks")?> </div>
    <div class="instructions"><?php __("You have access to these:")?></div>
    
    <div class="content">
    <table border="0" cellspacing="0" cellpadding="0">
        <tr>
            <td width="20%"><?php echo $html->link($html->image('icons/committee_add.gif'),array('controller'=>'committees','action'=>'add'),array('escape'=>false)); ?><br/><?php echo $html->link(__('Add committee',true),array('controller'=>'committees','action'=>'add'));?>
                <br /><?php __('Add a committee')?>
            </td>
            <td width="20%"><?php echo $html->link($html->image('icons/conf2.gif'),array('controller'=>'settings','action'=>'edit'),array('escape'=>false)); ?><br/><?php echo $html->link(__('Global settings',true),array('controller'=>'settings','action'=>'edit'));?>
                <br /><?php __("Manage global settings")?>
            </td width="20%">
            <td width="20%"><?php echo $html->link($html->image('icons/users2.gif'),array('controller'=>'users','action'=>'index'),array('escape'=>false)); ?><br/><?php echo $html->link(__('Users',true),array('controller'=>'users','action'=>'index'));?>
                <BR /><?php __("Manage users & committees")?>
            </td>
            <td width="20%"><?php echo $html->link($html->image('icons/todos.gif'),array('controller'=>'systemtodos','action'=>'index'),array('escape'=>false)); ?><br/><?php echo $html->link(__('To-dos',true),array('controller'=>'systemtodos','action'=>'index'));?>
                <br /><?php __("Default checklist prior to a meeting")?>
            </td>
            <td width="20%"><?php echo $html->link($html->image('icons/messages.gif'),array('controller'=>'templates','action'=>'index'),array('escape'=>false)); ?><br/><?php echo $html->link(__('Messages',true),array('controller'=>'templates','action'=>'index'));?>
                <br /><?php __("Manage the email templates")?>
            </td>
        </tr>
        <tr>
            <td><?php echo $html->link($html->image('icons/roles.gif'),array('controller'=>'roles','action'=>'index'),array('escape'=>false)); ?><br/><?php echo $html->link(__('Roles',true),array('controller'=>'roles','action'=>'index'))?>
                <br /><?php __('Manage roles and privileges')?>
            </td>
            <td><?php echo $html->link($html->image('icons/titles.gif'),array('controller'=>'titles','action'=>'index'),array('escape'=>false)); ?><br/><?php echo $html->link(__('Titles',true),array('controller'=>'titles','action'=>'index'));?>
                <br /><?php __("Manage all titles (Y.Bhg Dato', Tuan, Puan etc)")?>
            </td>
            <td><?php echo $html->link($html->image('icons/minuteformat.gif'),array('controller'=>'minutetypes','action'=>'index'),array('escape'=>false)); ?><br/><?php echo $html->link(__('Minute format',true),array('controller'=>'minutetypes','action'=>'index'));?>
                <br /><?php __("Manage minute format")?>
            </td>
            <td><?php echo $html->link($html->image('icons/postage_stamp_48.gif'),array('controller'=>'protocols','action'=>'index'),array('escape'=>false)); ?><br/><?php echo $html->link(__('Grades',true),array('controller'=>'protocols','action'=>'index'));?>
                <br /><?php __("Manage all grades (Turus I, Turus II, Jusa A etc)")?>
            </td>
            <td><?php echo $html->link($html->image('icons/edit-find1.gif'),array('controller'=>'logs','action'=>'index'),array('escape'=>false)); ?><br/><?php echo $html->link(__('Logs',true),array('controller'=>'logs','action'=>'index'));?>
                <br /><?php __("View Logs")?>
            </td>
        </tr>
        <tr>
            <td><?php echo $html->link($html->image('icons/statistics.gif'),array('controller'=>'logs','action'=>'report'),array('escape'=>false)); ?><br/><?php echo $html->link(__('Statistics',true),array('controller'=>'logs','action'=>'report'));?>
                <br /><?php __("Various reports")?>
            </td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
        </tr>
    </table>
    </div>
</div>
<?php endif;?>
